//返回值为需不需要关闭窗口
function yesOperator(){
  var retValue=addData();
  return retValue;
}
$(function () {
    $("input[name^='b_status']").click(function(){
        $("#b_status").val($(this).val());
    });
    deviceFormValid();
});
function deviceFormValid() {
    $("#deviceForm").validate({
        rules: {
            b_deviceCode: {
                required: true,
                minlength: 3,
                isCode:true
            },
            b_deviceName: {
                required: true,
                minlength: 3,
            },
            b_devicePwd:{
                required: true,
                minlength: 6,
                isPwd: true
            },
            b_rowSort: {
                required: true,
                minlength: 1,
                isPositiveInteger: true
            }
        },
        errorPlacement: function(error, element) {
            error.appendTo(element.parent());
        },
        errorElement: "span",
        errorClass: "errortips errortips-w200",
        success: 'valid',
        messages: {
            b_deviceCode: {
                required: " (必填)",
                minlength: " (不能少于 3 个字母)",
            },
            b_deviceName: {
                required: " (必填)",
                minlength: " (不能少于 3 个字母)",
            },
            b_devicePwd:{
                required: " (必填)",
                minlength: " (不能少于6位密码)"
            },
            b_rowSort:{
                isDigits: "输入正整数"
            }
        },
    });
}

function submitForm() {
    if($('#deviceForm').valid()){
        return false;
    }
    return {};
}

jQuery.validator.addMethod("isCode", function(value, element) {
    return this.optional(element) || /^[A-Z]{3}[0-9]{4}$/.test($("#b_deviceCode").val());
},'请输入3位大写字母＋4位数字');

